<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
if($_RQ['op']=='main'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		$this->plugin_setting('basic',$postdata);
		exi('设置成功');
	}
	$footernav =array(
		array('title'=>'首页','icon'=>'icon-shouye','action'=>'jy_videomerch/index/'),
		array('title'=>'店铺','icon'=>'icon-dianpu','action'=>'jy_videomerch/merchlist/'),
		array('title'=>'订单','icon'=>'icon-dingdan','action'=>'jy_videomerch/order/'),
		array('title'=>'我的','icon'=>'icon-wo1','action'=>'jy_videomerch/myhome/'),
	);
	$plugins =$this->plugins();
	$return['item']=$this->plugin_setting('basic');
	$return['item']['pcd_type']=$return['item']['pcd_type']?:'0';
	$return['item']['formfileds']=$return['item']['formfileds']?$return['item']['formfileds']:$formfileds;
	$return['item']['baomingfileds']=$return['item']['baomingfileds']?$return['item']['baomingfileds']:$baomingfileds;
	$return['item']['pingxuanfileds']=$return['item']['pingxuanfileds']?$return['item']['pingxuanfileds']:$pingxuanfileds;
	$return['item']['groupfileds']=$return['item']['groupfileds']?$return['item']['groupfileds']:$groupfileds;
	$return['item']['hudongfileds']=$return['item']['hudongfileds']?$return['item']['hudongfileds']:$hudongfileds;
	$return['item']['bgimgs']=$return['item']['bgimgs']?$return['item']['bgimgs']:$bgimgs;
	$return['item']['readtpls']=$return['item']['readtpls']?$return['item']['readtpls']:$readtpls;
	$return['item']['plugins']=$return['item']['plugins']?$return['item']['plugins']:$plugins[1]['list'];
	$return['item']['footernav']=$return['item']['footernav']?$return['item']['footernav']:$footernav;
	$return['item']['open_types']=$return['item']['open_types']?:';0;1;2;3;4;5;6;7;8;';
	$return['open_types']=$this->itemtypes();
	$htmls=array(
		'type'=>'edit',
		'desc'=>'参数设置',
		'tabs'=>$tabs,
		'edit_tab'=>true,
		'edits'=>array(
			array(
				'title'=>'基本信息',
				'list'=>array(
					array('type'=>'tip','title'=>'[温馨提示]：<red>
					</br>1、务必添加好【商户组】（移步：商户管理--商户分组--（开通费用，权重）--套餐权限--套餐自定义），这样才能根据前端用户的商户等级组，判断商户发起活动的权限！
					</br>2、商户管理--基本设置--试用期商户组，试用期天数，等设置好，可以实现试用期机制！
					</red>'),
					array('type'=>'string','title'=>'网站名称','name'=>'title'),
					array('type'=>'image','title'=>'网站logo','name'=>'logo'),
					array('type'=>'image','title'=>'顶部背景图','name'=>'topbg','help'=>'建议尺寸宽480，高300'),
					array('type'=>'image','title'=>'顶部广告图','name'=>'topimg','help'=>'建议尺寸宽480，高300'),
					array('type'=>'colorpicker','title'=>'首页背景色','name'=>'bgcolor'),
					array('type'=>'switch','title'=>'开启小程序审核模式?','name'=>'open_wxappsh','help'=>'开启小程序审核模式后，所有发帖信息，留言都不显示！包括我的圈里面'),
					//array('type'=>'switch','title'=>'开启留言审核?','name'=>'msg_shenhe'),
					array('type'=>'switch','title'=>'开启活动审核?','name'=>'item_shenhe'),
					array('type'=>'checkbox','title'=>'支持的提现方式','name'=>'withdrawtype','options'=>'withdraw'),
					array('type'=>'switch','title'=>'开启自动注册商户?','name'=>'zc_merch','help'=>'默认进入商户小店时需要手动注册商户！'),
					array('type'=>'switch','title'=>'开启余额红包?','name'=>'isideal_money','help'=>'开启余额红包后，就关闭了微信红包，改用账户余额红包，红包资金进入奖金池，奖金池可以提现或转到余额'),
					
					array('type'=>'text','title'=>'平台描述','name'=>'desc'),
					array('type'=>'string','title'=>'分享标题','name'=>'share_title'),
					array('type'=>'image','title'=>'分享图片','name'=>'share_image'),
					array('type'=>'text','title'=>'分享描述','name'=>'share_desc'),
				)
			),
			array(
				'title'=>'前端店铺广告',
				'list'=>array(
					array('type'=>'image','title'=>'广告1','name'=>'indexad'),
					array('type'=>'link','title'=>'广告1链接','name'=>'indexadurl'),
					array('type'=>'image','title'=>'开通会员广告图','name'=>'indexad2'),
				)
			),
			array(
				'title'=>'活动背景',
					'list'=>array(
						array(
							'type'=>'array',
							'name'=>'bgimgs',
							'add_tip'=>'添加一个活动背景',
								'list'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'背景图片'),
								),
								'details'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'背景图片','help'=>''),
								)
						)
					)
			),
			array(
				'title'=>'页面UI',
				'list'=>array(
					//array('type'=>'colorpicker','title'=>'项目顶部颜色','name'=>'r_color','help'=>'自定义系统颜色系，默认： red'),
					array('type'=>'image','title'=>'会员顶部图片','name'=>'h_img','help'=>'建议尺寸：高360px*宽640px'),
					array('type'=>'colorpicker','title'=>'会员顶部颜色','name'=>'h_color','help'=>'自定义系统颜色系，默认： red'),
					array('type'=>'image','title'=>'内容顶部图片','name'=>'o_img','help'=>'建议尺寸：高360px*宽640px'),
					//array('type'=>'colorpicker','title'=>'活动列表顶部颜色','name'=>'o_color','help'=>'自定义系统颜色系，默认： red'),
					array('type'=>'image','title'=>'发红包弹窗背景图','name'=>'o_hongbao','help'=>'发红包弹窗背景图，建议尺寸：高520px*宽360px'),
				)
			),
			array(
				'title'=>'底部导航',
					'list'=>array(
									array('type'=>'array','name'=>'footernav','add_tip'=>'添加一个底部导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),
										array('type'=>'string','name'=>'action','title'=>'导航链接'),							
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),							
										array('type'=>'link','name'=>'action','from'=>'action','title'=>'导航链接'),
									)
								),
					)
			),
			array(
				'title'=>'会员中心DIY导航',
					'list'=>array(
									array('type'=>'array','name'=>'homenav','add_tip'=>'添加一个DIY导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),
										array('type'=>'string','name'=>'action','title'=>'导航链接'),							
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),							
										array('type'=>'link','name'=>'action','from'=>'action','title'=>'导航链接'),
									)
								),
					)
			),
			array(
				'title'=>'专家顾问',
				'list'=>array(
					array('type'=>'image','title'=>'顾问头像','name'=>'kf_logo','help'=>'建议尺寸：宽360px,高:360px'),
					array('type'=>'string','title'=>'顾问链接','name'=>'kf_link','help'=>'可以使用企业微信客服链接，或者建议使用：一篇微信公众号文章，文章内容引导关注公众号/加入启用微信二维码，进行在线咨询'),
				)
			),
			/*array(
				'title'=>'小程序广告设置',
				'list'=>array(
					array('type'=>'string','title'=>'微信小程序活动间广告ID','name'=>'wxapp_ad01','help'=>'例如：adunit-513cf0c735a3d48a'),
					array('type'=>'string','title'=>'支付宝小程序活动间广告ID','name'=>'aliapp_ad01'),
					array('type'=>'string','title'=>'百度小程序活动间广告ID','name'=>'baiduapp_ad01'),
					array('type'=>'string','title'=>'头条小程序活动间广告ID','name'=>'ttapp_ad01'),
					array('type'=>'image','title'=>'自定义广告图片','name'=>'diy_adimg','help'=>'建议尺寸：宽580px,高:200px'),
					array('type'=>'link','from'=>'action','title'=>'自定义广告链接','name'=>'diy_adlink'),
					array('type'=>'string','title'=>'自定义广告标题','name'=>'diy_adtitle'),
					array('type'=>'switch','title'=>'开启联盟广告?','name'=>'is_lianad'),
					array('type'=>'text','title'=>'联盟广告JScode','name'=>'lian_adcode'),
				)
			),*/
		),
	);
	$return['withdraw']=$this->pay_types;
	$return['types']=get_form_types();
	
	$return['ismust']=array('0'=>'非必填','1'=>'必填');
	$return['pcd_types']=array('0'=>'区/县级圈','1'=>'市级圈','2'=>'省级圈');
	$return['become_type']=array('0'=>'全局统一上下级关系','1'=>'活动独立上下级关系');
	$return['become_child']=array('0'=>'首次点击分享链接/扫码','1'=>'首次下单','2'=>'首次付款');
	$return['htmls']=$htmls;
	exi($return);
}

if($_RQ['op']=='get_item'){
	//会员列表
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$return['params']=$params=array();
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1,'noshow'=>0);
	$fields=array('title','id','status','type','createtime');
	if($_RQ['find']){
		$field=in_array($_RQ['field'],$fields)?$_RQ['field']:'title';
		$params[$field.' like']='%'.$_RQ['find'].'%';
		$return['params']['find']=$_RQ['find'];
		$return['params']['field']=$field;
	}
	$list=pdo_getslice('jy_quanhuo_item',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			//整理返回数据
			if($_RQ['many']==1){
				$item['res']=array('id'=>$item['id'],'title'=>$item['title']);
			}else{
				$item['res']=$item['id'];
			}
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['htmls']=array(
		'type'=>'list',
		'list'=>array('data'=>'list','tip'=>'只显示审核通过的活动！','del_one'=>false,'delall'=>false,'edit'=>false,'list'=>array(
		    array('name'=>'id','title'=>'id','type'=>'string'),
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'switch'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'res','title_field'=>'id','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'find','select_name'=>'field','select_title'=>'筛选','is_radio'=>true,'options'=>'fields'),
	);
	$return['fields']=array(
		'title'=>'标题',
	);
	exi($return);
}